package com.example.my_helper;

public class MyMQTTConnection {
    public static int connection_index = 0;
    public int connecttion_id;
    public String host;
    public int port;
    public String username;
    public String password;
    public String client_id;
    public int keep_alive = 60;
    public boolean clean_seasion = true;
    public boolean use_ssl = false;
    public String last_will_topic;
    public String last_will_message;
    public int last_will_qos;
    public boolean last_will_retained;

    public MyMQTTConnection(String host, int port){
        this.connecttion_id = connection_index;
        this.host = host;
        this.port = port;
        this.username = "";
        this.password = "";
        this.client_id = generate_client_id();
        connection_index++;
    }

    public MyMQTTConnection(String host, int port, String username, String password, String client_id){
        this.connecttion_id = connection_index;
        this.host = host;
        this.port = port;
        this.username = username;
        this.password = password;
        if(client_id != null && client_id.length() > 0)
            this.client_id = client_id;
        else
            this.client_id = generate_client_id();
        connection_index++;
    }

    public static String generate_client_id(){
        return "client-"+ System.currentTimeMillis()%1000000;
    }
}
